package com.keyinong.park.homeadapter;

import java.util.ArrayList;

import com.keyinong.park.R;
import com.keyinong.park.homebean.PotRemarkBean;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class PotRemarkAdapter extends BaseAdapter {
	ArrayList<PotRemarkBean> list;
	Context context;

	public PotRemarkAdapter(ArrayList<PotRemarkBean> list, Context context) {
		super();
		this.list = list;
		this.context = context;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		ViewHandle handle;
		if (view == null) {
			handle = new ViewHandle();
			view = LayoutInflater.from(context).inflate(
					R.layout.item_list_potremark, null);
			handle.tv_potRemarkNum = (TextView) view
					.findViewById(R.id.tv_potRemarkNum);
			handle.tv_potRemark = (TextView) view
					.findViewById(R.id.tv_potRemark);
			handle.tv_potRemarkTime = (TextView) view
					.findViewById(R.id.tv_potRemarkTime);
			view.setTag(handle);
		}else{
		    handle=(ViewHandle) view.getTag();
		}
		handle.tv_potRemarkNum.setText(position+1+"");
		handle.tv_potRemark.setText(list.get(position).getContent());
		handle.tv_potRemarkTime.setText(list.get(position).getUpdated_at());
		return view;
	}

	private class ViewHandle {
		TextView tv_potRemarkNum;
		TextView tv_potRemark;
		TextView tv_potRemarkTime;

	}

}
